package _5Recursion.src.MultiRecursion;
/*行：i;列：j
* 当j=0||i=j时，[i][j]=1
* [i][j]=[i-1][j-1]+[i-1][j]* */

/*需求：求某一行某一列的值*/
/*未优化前，优化的话可以使用二维数组*/
public class yanghui {
    public static int element(int i, int j) {
        if (i == j || j == 0) {
            return 1;
        }
        return element(i - 1, j - 1) + element(i - 1, j);
    }

    public static void print(int n) {
        for (int i = 0; i < n; i++) {
            int num = (n - i - 1)*2;//2和后面的-4d有关
            for (int k = 0; k < num; k++) {
                System.out.printf(" ");
            }
            for (int j = 0; j <= i; j++) {
                System.out.printf("%-4d", element(i, j));
            }
            System.out.println();
        }
    }
    public static void main(String[] args) {
        print(10);
    }
}
